package org.achartengine.internal.a;

import org.achartengine.internal.chart.k;

/* loaded from: classes2.dex */
public class c extends a {
    public c(k kVar) {
        super(kVar);
    }

    public void a(float f, float f2, float f3, float f4) {
        double[] a = a();
        double[] ab = this.b.ab();
        boolean z = ab != null && ab.length == 4;
        double[] g = this.a.g();
        if (a[0] == a[1] && g[0] == g[1]) {
            return;
        }
        if (a[2] == a[3] && g[2] == g[3]) {
            return;
        }
        a(a);
        double[] c = this.a.c(f, f2);
        double[] c2 = this.a.c(f3, f4);
        double d = c[0] - c2[0];
        double d2 = c[1] - c2[1];
        if (this.b.S()) {
            if (z) {
                if (ab[0] > a[0] + d) {
                    a(ab[0], ab[0] + (a[1] - a[0]));
                } else if (ab[1] < a[1] + d) {
                    a(ab[1] - (a[1] - a[0]), ab[1]);
                } else {
                    a(a[0] + d, a[1] + d);
                }
            } else {
                a(a[0] + d, a[1] + d);
            }
        }
        if (this.b.T()) {
            if (z) {
                if (ab[2] > a[2] + d2) {
                    b(ab[2], ab[2] + (a[3] - a[2]));
                    return;
                } else if (ab[3] < a[3] + d2) {
                    b(ab[3] - (a[3] - a[2]), ab[3]);
                    return;
                } else {
                    b(a[2] + d2, a[3] + d2);
                    return;
                }
            }
            b(a[2] + d2, a[3] + d2);
        }
    }
}
